package com.taotao.web.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.taotao.common.service.HttpClientService;
import com.taotao.web.vo.CommonResult;
import com.taotao.web.vo.Order;
@Service
public class OrderService {
	
	@Autowired
	private HttpClientService httpClientService;
	
	public static final ObjectMapper mapper = new ObjectMapper();

	public CommonResult save(Order order) throws JsonProcessingException {
		String params = mapper.writeValueAsString(order);
		return httpClientService.doJsonPost("http://order.taotao.com/order/create", params, new TypeReference<CommonResult>() {
		});
	}

	public Order queryOrderById(String id) {
		return httpClientService.doGet("http://order.taotao.com/order/query/"+id, new TypeReference<Order>() {
		});
	}

}
